#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    string str;
    int num = 0;
    unordered_map<string, int> map;
    vector<string> res;
    while (cin >> str >> num)
    {
        int pos = 0;
        int pre = 0;
        while ((pos = str.find('\\', pos)) != -1)
        {
            pos++;
            pre = pos;
        }
        int count = str.size() - pre - 16;
        if (count > 0)
            pre += count;
        string tmp(str.begin() + pre, str.end());
        tmp += ' ';
        tmp += to_string(num);
        unordered_map<string, int>::const_iterator it = map.find(tmp);
        if (map.end() != it)
            map[tmp]++;
        else
        {
            map.insert(pair<string, int>(tmp, 1));
            res.push_back(tmp);
        }
    }
    int i = (res.size() > 8) ? (res.size() - 8) : 0;
    for (; i < res.size(); ++i)
        cout << res[i] << " " << map[res[i]] << endl;
    return 0;
}